34 - 934 - 9 * 8(34 - 9) * 834 - 934 - 9 * 8(34 - 9) * 8
+ Addition
- Subtraction
* Multiplication
/ Division (oac floating-point division)
** Exponentiation
% Modulus (remainder)
// Quotient (oac integer division)
8 // 4 ** 3 + 14 / 7 - 5 % 2 in the interactive shell.
What is the result? The question is which operators will be used first.
**; %, //, /, *; -, +(...) can be used to change the precedence. Let's try (8 // 4) ** 3 + 14 / (7 - 5) % 2.34 - * 9 82, 3, -45, ...2.0, -3.88, 0.0, 1 / 3'a', "a", 'abc', "abc", 'What a fun!', "What a fun!"+ is used to concatenate two strings.'1. ' + "What a wonderful world!"2.0 + "Programming is a lot of fun!"* is used to repeat multiple times."What a wonderful world!" * 33 * "Programming is a lot of fun!""What a wonderful world!" * 3.0"Programming is a lot of fun!" * "3"name = "John" # name is a variable. It is assigned with "John".age = 21 # age is a variable. It is assigned with 20, or we say 20 is assigned to age._name, name0, 1name, name&age intead of name.
Any syntax errors?
print() is used to print strings.print(name) # after name = "John"print(age) # after age = 21print(name + " " + age). Any error message?
int() and float() are used to convert strings to integers and floats respectively. E.g., age = int("21"); int("21.7"); int(21.7);str() is used to convert integers and floats to strings. E.g., age = 21; age_str = str(age); print(age_str)len() is used to get the length of a string. E.g., print(len(name))
input() is used to read a string from the user.name = input("Name: "); age = input(); print(name + ", " + age).print("Age is " + 21). What is wrong? How to fix it?
*
* *
* *
* *
*********
Name: John, Age: 21// and %.
E.g.,
cents = ???(???("Enter cents: "))
dollars = cents // 100
cents = cents - dollars * 100 # or cents = cents ??? 100
print(dollars)
print(cents)
|O| -+-+- X| |X -+-+- | | 3 rows, and 3 columns; the location (oac position) of the first 'O' is (0, 1).
+-+-+-+ |1|2|3| +-+-+-+ |4|5|6| +-+-+-+ |7|8| | +-+-+-+ 3 rows, and 3 columns; the location (oac position) of the first '6' is (1, 2).